﻿<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" MasterPageFile="~/Views/Shared/Site.Master" %>

<asp:Content runat="server" ID="PageTitle" ContentPlaceHolderID="PageTitle">
    <title>项目中的工作任务</title>
</asp:Content>
<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="PageStyles">
    <link href="../../Content/project/project.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/project/project.workitemlist.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/ui.button.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/table_jui.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .imgAdd
        {
            background: url(./../Content/images/plus.png) no-repeat;
        }
        .text
        {
            width: 200px;
        }
        
        .hours
        {
            width: 60px;
        }
        
        .tbl
        {
            border: 0px;
        }
        .tbl tr td
        {
            text-align: left;
        }
        .tbl tr
        {
            text-align: left;
        }
        .dataTables_wrapper
        {
            min-height: 50px;
        }
        .txtprojectName
        {
            color: #aaa;
        }
    </style>
</asp:Content>
<asp:Content runat="server" ID="PageScripts" ContentPlaceHolderID="PageScripts">
    <script src="../../Scripts/jquery.dataTables.js" type="text/javascript"></script>
    <script src="../../Scripts/Project/projectTab.js" type="text/javascript"></script>
    <script type="text/javascript">
        //************* URL常量
        var myConvertor = null;
        
        var Global = {
            'project': null,
        };  

        //************* Accessor访问器
        var EzAccessor = {};

        function CreateAccessor() {
            //实现服务器交互方法
            EzAccessor = {
                "getProjectInfo": function () { 
                    return <%= WebJsonExtension.ToJson(Model.ProjectInfo) %>;
                }

            };
        }

        function showProjectInfo(project){
            if (PorjectInfo) {
                PorjectInfo.Show(project);
            }
        }

        function initFilterControl() {
            EzTipsManager.addTipBox('#tip_workitemFilter', 'tip_workitemFilter');
            EzTipsManager.showTipBox('tip_workitemFilter');

            WorkItemFilter.Init(Global.project);
            WorkItemFilter.InitCallBack(function (e) {
                filterArgs = $.extend(filterArgs, e);
                args.project = Global.project;

                if (filterArgs.isFinish == "true") {
                    args.myConvertor = [" ", "内容", "完成时间", "负责人"];
                    $('#title-wokitem-list').html('已经完成的工作任务');
                } else {
                    $('#title-wokitem-list').html('进行中的工作任务');
                    args.myConvertor = [" ", "内容", "到期",  "负责人","操作"];
                }
                $('#divWorkitems').workitemList(args);
            });
        }


        var filterArgs =  {};
        
        var args = {
            myConvertor: [" ", "内容", "到期",  "负责人","操,作"],
            GetWorkitemListService: function(callback)
            {
                EzDesk.Service.GetWorkItems_Sync(callback,filterArgs);
            }
            
        };

        //初始化页面
        function initPage() {
            CreateAccessor();
            Global.project = EzAccessor.getProjectInfo();
            filterArgs.projectId = Global.project.Id;
            showProjectInfo(Global.project);
            
            initFilterControl();
        }

        //初始化事件
        function initPageEvent() {
            $('#btn-add-workitem').click(function () {
                if (WorkitemCreatorSimple) {
                    WorkitemCreatorSimple.Show(true, null, Global.project);
                    WorkitemCreatorSimple.SubmitSuccessCallback = function (workitemId) {
                        $('#status-list').get(0).selectedIndex = 0;
                        $('#project-list').get(0).selectedIndex = 0;
                        $('#owner-list').get(0).selectedIndex = 0;

                        $('#title-wokitem-list').html('进行中的工作任务');
                        args.myConvertor = [" ", "内容", "到期", "负责人", "操作"];
                        
                        filterArgs = $.extend(filterArgs , {
                            isFinish:false,
                            onlyMine:false,
                            onlyMyAssign:false,
                        });
                        
                        $('#divWorkitems').workitemList(args);
                        $('#divWorkitems').workitemList('Highlight', workitemId, 5000);
                    }
                }
            });

            $('#tabs').projectTab(Global.project, 'link-workitems');
        }

        $(function () {
            initPage();
            initPageEvent();
        });

    </script>
</asp:Content>
<asp:Content runat="server" ID="PageHead" ContentPlaceHolderID="PageHead">
    <%
        Html.RenderPartial("_sayHello"); %>
</asp:Content>
<asp:Content runat="server" ID="Page" ContentPlaceHolderID="PageContent">
    <div id="page-head" class="page-head">
        <div id="links">
            <a href="/project/ProjectList" class="head">返回项目列表</a> <a href="/project/workitemList"
            class="head">所有工作任务</a>
        </div>
        <% Html.RenderPartial("_projectInfo"); %>
        <div id="tabs">
        </div>
    </div>
    <div id="page-body">
        <div class="content">
            <div class="content-section content-section">
                <div id="div-add-workitem" style="float: right;">
                    <div id="btn-add-workitem">
                        添加工作任务
                    </div>
                    <script type="text/javascript">
                        $(function () {
                            $("#btn-add-workitem").button({
                                icons: {
                                    primary: "ui-icon-circle-plus"
                                },
                                text: true
                            });
                        });
                    </script>
                </div>
                <p id="title-wokitem-list" class="entry-explanation" style="line-height: 35px;">
                </p>
                <div id="divWorkitems" class="tableContainer">
                </div>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content runat="server" ID="PageShortcut" ContentPlaceHolderID="PageShortcut">
</asp:Content>
<asp:Content runat="server" ID="PageFoot" ContentPlaceHolderID="PageFoot">
    <div>
        <% Html.RenderPartial("_workitemCreatorSimple"); %>
    </div>
    <div id="tip_workitemFilter" style="display: none;">
        <% Html.RenderPartial("_workitemFilter"); %>
    </div>
</asp:Content>
